﻿<!--#include file="const.inc"-->
<%
'====================================================================
' 感谢使用晴天3G智能建站系统..
' 作者:梁永强.QQ:766750857
' 官方网址:wap.qt3g.com
' 声明:软件版权归作者所有,没有经过作者本人同意不得非法破解和传播本程序
'====================================================================
%>
<%
dim listid,id
		listid=Request.QueryString("listid")
		if not isnumeric(listid) then listid=0
		if listid="" then listid=0
		listid=clng(listid)

		id=Request.QueryString("id")
		if not isnumeric(id) then id=0
		if id="" then id=0
		id=clng(id)
if sid="Null" then
Response.Redirect "/login.asp?sid=" & sidd & "&url=/bbs/viewv.asp?id="&id&"@@listid="&listid
Response.end
end if
IF Request.QueryString("Action")="login" Then
	call loginn
else
	call index
end if
end Function

Function index
dim listid,id
		listid=Request.QueryString("listid")
		if not isnumeric(listid) then listid=0
		if listid="" then listid=0
		listid=clng(listid)

		id=Request.QueryString("id")
		if not isnumeric(id) then id=0
		if id="" then id=0
		id=clng(id)
select case v
case "0"
we0="<br/>"
hr="-------------<br/>"
%>
<card title="下载论坛文章"><p align="<%=qingtian.px%>">
<%
case "1"
hr=""
zi="<span style=""color:#FF5500"">"
zi0="</span>"
we="<div class=""footer"">"
sou="<div class=""block4"">"
dao="<div class=""navi"">"
we0="</div>"
%>
<title>下载论坛文章</title>
</head>
<body>
<!--#include virtual="/css.inc"-->
<%

End Select
%>
<%=qingtian.qingsav("64")%><%=we%>
<%if qingtian.vip(qingtian.nid)="VIP会员" then%>
你好,由于你是本站VIP会员可以免费下载此资源,
<%else%>
下载此论坛文章需花费<%=qingtian.confff("bit")%><%=qingtian.bi%>(<%=zi%>成为VIP会员，可以终身免币下载，还可享受更多特权<%=zi0%>),
<%end if%>
确定要下载吗？<%=we0%><%=sou%>
<a href='downtxt.asp?Action=login&amp;listid=<%=listid%>&amp;id=<%=id%>&amp;sid=<%=sidd%>'>是的</a>|<a href='viewv.asp?listid=<%=listid%>&amp;id=<%=id%>&amp;sid=<%=sidd%>'>取消</a><%=we0%>
<%=qingtian.qingsav("65")%>
<%=we%><a href='viewv.asp?listid=<%=listid%>&amp;id=<%=id%>&amp;sid=<%=sidd%>'>返回上级</a><%=we0%>

<%
End Function

Function loginn
dim listid,id,name,content,strr,fs,xTextFile,sql,rs,tip,yd,path,txt,re,nid
		listid=Request.QueryString("listid")
		if not isnumeric(listid) then listid=0
		if listid="" then listid=0
		listid=clng(listid)

		id=Request.QueryString("id")
		if not isnumeric(id) then id=0
		if id="" then id=0
		id=clng(id)
select case v
case "0"
we0="<br/>"
hr="-------------<br/>"
%>
<card title="下载论坛文章"><p align="<%=qingtian.px%>">
<%
case "1"
hr=""
zi="<span style=""color:#FF5500"">"
zi0="</span>"
we="<div class=""footer"">"
sou="<div class=""block4"">"
dao="<div class=""navi"">"
we0="</div>"
%>
<title>下载论坛文章</title>
</head>
<body>
<!--#include virtual="/css.inc"-->
<%

End Select
Set Rs = Server.CreateObject("Adodb.Recordset")
Sql = "select top 1 nid,name,content from qingtian_bbs_forum where listid="&listid&" and lock<>True and id="&id
	Rs.Open Sql,conn,1,1
	if not (rs.bof and rs.eof)  then
        nid=rs("nid")
        name=Replace(rs("name"),"/","")
        name=Replace(name,";","")
        name=Replace(name,"%","")
        content=rs("content")
if qingtian.vip(qingtian.nid)="VIP会员" then
errss=1
else
If conn.execute("select money from [qingtian_user] where sid='"&qingtian.Formatsid(sid)&"'")("money")<qingtian.confff("bit") Then 
                        Tip="出错了！你的"&qingtian.bi&"不够哦！"
                        errss=0
                        else
                        qingtian.payy("-"&qingtian.confff("bit"))
strr=""&qingtian.nid&"tt你好,你浏览的帖子(url=/bbs/viewv.asp?id="&id&"&listid="&listid&"&sid=[sid])"&name&"(/url)下载成功,系统自动扣除"&qingtian.confff("bit")&""&qingtian.bi&"!"
qingtian.addnfo(strr)
                        end if
                        end if


        else
                        Tip="出错了！你下载的帖子不存在或已经锁定！"
                        errss=0

        end if
	Rs.close
	set rs=nothing
	Set re=new RegExp
	re.IgnoreCase =true
	re.Global=True
	if instr(1,content,"[/re]",1)>0 then	
		re.Pattern="(^.*)(\[re\])(.+?)(\[\/re\])(.*)"
           if nid=qingtian.nid or qingtian.bz(listid)=true then
		  content=re.Replace(content,"$1$3$5")	
              else

		if sid="Null" then
			content= re.Replace(content,"$1<br/>[隐藏内容回复后才能浏览]<br/>$5")
		elseif Not(conn.execute("select top 1 id from qingtian_bbs_reforum where nid="&nid&" and topicid="&id).eof) then		
		  content=re.Replace(content,"$1$3$5")	
		  else
		  content= re.Replace(content,"$1<br/>[隐藏内容回复后才能浏览]<br/>$5")
	  end if
	end if
	end if		
	set re=Nothing
if errss<>"0" then
	content=replace(content,"<br/>",chr(13) & chr(10))
	content=replace(content,"(br)",chr(13) & chr(10))
	content=replace(content,"[br]",chr(13) & chr(10))
	content=replace(content,"\\",chr(13) & chr(10))
yd =  name
yd =  yd & chr(13) & chr(10)
yd =  yd & "-------"
yd =  yd & chr(13) & chr(10)
yd =  yd &"来源:"& request.ServerVariables("Server_NAME")
yd =  yd & chr(13) & chr(10)
yd =  yd & "-------"
yd =  yd & chr(13) & chr(10)
yd =  yd & content
yd =  yd & chr(13) & chr(10)
yd =  yd & "-------"
yd =  yd & chr(13) & chr(10)
yd =  yd & "本TXT下载于"&now()
yd =  yd
path= "bbs/txt/"&name&".txt"
dir = "/bbs/txt"
SET Fso = CreateObject("Scripting.FileSystemObject")
on error resume next
Fso.DeleteFolder Server.MapPath(dir),True
set fso=nothing
qingtian.CreateFolder dir
qingtian.CreateFile yd,path
Response.ContentType = "application/java-archive"
Response.Redirect "/bbs/txt/"&name&".txt"
else
Response.Write we&tip&we0
%>
<%=sou%><a href='viewv.asp?listid=<%=listid%>&amp;id=<%=id%>&amp;sid=<%=sidd%>'>返回上级</a><%=we0%>
<%

end if
end function
%>